package cn.yunhe.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.yunhe.biz.CateBiz;
import cn.yunhe.entity.Cate;

public class CateServlet extends HttpServlet{
	
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		String catename=request.getParameter("catename");
		Cate c=new Cate();
		c.setCateName(catename);
		
		CateBiz cateBiz=new CateBiz();
		boolean flag=cateBiz.addCate(c);		
		
		if(flag){
			request.getRequestDispatcher("admin/cateList.jsp").forward(request, response);
		}else{
			response.sendRedirect("addCate.jsp");
		}
 	}
	
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		doGet(req, resp);
 	}
}
